<?php

namespace app\admin\controller;

use app\admin\service\HomeService;

class HomeController extends CommonController
{
    // 概览
    public function getOverviewData(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(HomeService::class, [$this->returnData, $this->params]);
        $admin_id = $this->getSessionIdVar($this->params['token'], 'id');
        $this->returnData = $service->getOverviewData($admin_id);
        return $this->return_result($this->returnData);
    }

    // 统计
    public function getStatisticsData(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $admin_id = $this->getSessionIdVar($this->params['token'], 'id');
        $service = $this->app->invokeClass(HomeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getStatisticsData($admin_id);
        return $this->return_result($this->returnData);
    }

    // 统计页的订单搜索
    public function getSearchOrderList(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(HomeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getSearchOrderList();
        return $this->return_result($this->returnData);
    }

    // 获取脚本运行状态
    public function getJavaScriptStatus(){
        if($this->returnData["code"] !== 0){
            return $this->return_result($this->returnData);
        }
        $service = $this->app->invokeClass(HomeService::class, [$this->returnData, $this->params]);
        $this->returnData = $service->getJavaScriptStatus();
        return $this->return_result($this->returnData);
    }
}
